class SessionsController < ApplicationController

  skip_before_filter :require_login

  def new
    @user = User.new
  end

  def create
    reset_session
    user = User.authenticate(params[:user][:email], params[:user][:password])
    session[:user_id] = user.id
    redirect_to root_url, :notice => "Logged in successfully"
  rescue AuthenticationError
    render :new
  end

  def destroy
    reset_session
    redirect_to root_url
  end
end
